<?php

class Mojito_Controller_Plugin_Accept extends Zend_Controller_Plugin_Abstract
{	
	public function dispatchLoopStartup(Zend_Controller_Request_Abstract $Request)
	{
		$header = $Request->getHeader('accept');
		switch (true)
		{
			case (strstr($header,'application/json')):
				$Request->setParam('format','json');
				break;
			case (strstr($header,'application/xml')&&!strstr($header,'html')):
				$Request->setParam('format','xml');
				break;
		}
	}
}